<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="g">GET请求</button>
    <button class="p">POST请求</button>

    <div class="box"></div>
    <script src="./封装ajax.js"></script>
    <script>
        let g = document.querySelector(".g");
        let p = document.querySelector(".p");
        let box = document.querySelector(".box");


        g.addEventListener("click",function(){
            Ajax("get",
            "http://studentback.dfbuff.top/getMethod",
            { "type": "图片" },
            function (res) {
                console.log(res);
                res.result.forEach(function (item) {
                    console.log(item);
                    box.innerHTML += `<img src=${item.content} width='100'><br>`
                })
            }
        )
        })
        

        Ajax("post",
            "http://192.168.31.117:3000/postMethod",
            { "type": "冷笑话" },
            function (res) {
                console.log(res);
            }
        )
    </script>
</body>

</html>